<!doctype html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang=""> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8" lang=""> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9" lang=""> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js" lang="">
	<!--<![endif]-->

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>Ela Admin - HTML5 Admin Template</title>
		<meta name="description" content="Ela Admin - HTML5 Admin Template">
		<meta name="viewport" content="width=device-width, initial-scale=1">

		<link rel="stylesheet" href="assets/css/normalize.css">
		<link rel="stylesheet" href="assets/css/bootstrap.min.css">
		<link rel="stylesheet" href="assets/css/font-awesome.min.css">
		<link rel="stylesheet" href="assets/css/themify-icons.css">
		<link rel="stylesheet" href="assets/css/pe-icon-7-filled.css">
		<link rel="stylesheet" href="assets/css/flag-icon.min.css">
		<link rel="stylesheet" href="assets/css/cs-skin-elastic.css">
		<link rel="stylesheet" href="assets/css/style.css">

		<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,600,700,800' rel='stylesheet' type='text/css'>

		<!-- <script type="text/javascript" src="https://cdn.jsdelivr.net/html5shiv/3.7.3/html5shiv.min.js"></script> -->

	</head>

	<body>
		<!-- Left Panel -->
		<aside id="left-panel" class="left-panel">
			<nav class="navbar navbar-expand-sm navbar-default">
				<div id="main-menu" class="main-menu collapse navbar-collapse">
					<ul class="nav navbar-nav">
						<li class="active">
							<a href="index.html"><i class="menu-icon fa fa-laptop"></i>后台管理 </a>
						</li>
						<li class="menu-item-has-children dropdown">
							<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <i class="menu-icon fa fa-cogs"></i>管理员中心</a>
							<ul class="sub-menu children dropdown-menu">
								<li><i class="fa fa-id-card-o"></i>
									<a href="ui-cards.html">个人信息</a>
								</li>
								<li><i class="fa fa-file-word-o"></i>
									<a href="forget.html">修改密码</a>
								</li>
							</ul>
						</li>
						<li class="active">
							<a href="hospital.html"> <i class="menu-icon fa fa-table"></i>医院管理</a>
						</li>
						<li>
							<a href="doctor.html"> <i class="menu-icon fa fa-th"></i>医生管理</a>
						</li>

						<li class="menu-item-has-children dropdown">
							<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <i class="menu-icon fa fa-tasks"></i>用户管理</a>
							<ul class="sub-menu children dropdown-menu">
								<li><i class="menu-icon fa fa-fort-awesome"></i>
									<a href="font-fontawesome.html">Font Awesome</a>
								</li>
								<li><i class="menu-icon ti-themify-logo"></i>
									<a href="font-themify.html">Themefy Icons</a>
								</li>
							</ul>
						</li>

						<li>
							<a href="disease.html"><i class="menu-icon fa fa-street-view"></i>疾病管理</a>
						</li>
						<!-- /.menu-title -->
						<li>
							<a href="drug.html"> <i class="menu-icon fa fa-glass"></i>药品管理</a>
						</li>

						<li class="menu-item-has-children dropdown">
							<a href="" class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <i class="menu-icon fa fa-bar-chart"></i>统计排行</a>
							<ul class="sub-menu children dropdown-menu">
								<li><i class="menu-icon fa fa-line-chart"></i>
									<a href="hosrank.html">医院统计</a>
								</li>
								<li><i class="menu-icon fa fa-area-chart"></i>
									<a href="doctorrank.html">医生统计</a>
								</li>
								<li><i class="menu-icon fa fa-pie-chart"></i>
									<a href="charts-peity.html">疾病统计</a>
								</li>
							</ul>
						</li>
					</ul>
				</div>
				<!-- /.navbar-collapse -->
			</nav>
		</aside>
		<!-- /#left-panel -->

		<!-- Right Panel -->

		<div id="right-panel" class="right-panel">

			<!-- Header-->
			<header id="header" class="header">
				<div class="top-left">
					<div class="navbar-header">
						<a class="navbar-brand" href="./"><img src="images/logo.png" alt="Logo"></a>
						<a class="navbar-brand hidden" href="./"><img src="images/logo2.png" alt="Logo"></a>
						<a id="menuToggle" class="menutoggle"><i class="fa fa-bars"></i></a>
					</div>
				</div>
				<div class="top-right">
					<div class="header-menu">
						<div class="header-left">
							<button class="search-trigger"><i class="fa fa-search"></i></button>
							<div class="form-inline">
								<form class="search-form">
									<input class="form-control mr-sm-2" type="text" placeholder="Search ..." aria-label="Search">
									<button class="search-close" type="submit"><i class="fa fa-close"></i></button>
								</form>
							</div>

							<div class="dropdown for-notification">
								<button class="btn btn-secondary dropdown-toggle" type="button" id="notification" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                <i class="fa fa-bell"></i>
                                <span class="count bg-danger">3</span>
                            </button>
								<div class="dropdown-menu" aria-labelledby="notification">
									<p class="red">You have 3 Notification</p>
									<a class="dropdown-item media" href="#">
										<i class="fa fa-check"></i>
										<p>Server #1 overloaded.</p>
									</a>
									<a class="dropdown-item media" href="#">
										<i class="fa fa-info"></i>
										<p>Server #2 overloaded.</p>
									</a>
									<a class="dropdown-item media" href="#">
										<i class="fa fa-warning"></i>
										<p>Server #3 overloaded.</p>
									</a>
								</div>
							</div>

							<div class="dropdown for-message">
								<button class="btn btn-secondary dropdown-toggle" type="button" id="message" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                <i class="fa fa-envelope"></i>
                                <span class="count bg-primary">4</span>
                            </button>
								<div class="dropdown-menu" aria-labelledby="message">
									<p class="red">You have 4 Mails</p>
									<a class="dropdown-item media" href="#">
										<span class="photo media-left"><img alt="avatar" src="images/avatar/1.jpg"></span>
										<div class="message media-body">
											<span class="name float-left">Jonathan Smith</span>
											<span class="time float-right">Just now</span>
											<p>Hello, this is an example msg</p>
										</div>
									</a>
									<a class="dropdown-item media" href="#">
										<span class="photo media-left"><img alt="avatar" src="images/avatar/2.jpg"></span>
										<div class="message media-body">
											<span class="name float-left">Jack Sanders</span>
											<span class="time float-right">5 minutes ago</span>
											<p>Lorem ipsum dolor sit amet, consectetur</p>
										</div>
									</a>
									<a class="dropdown-item media" href="#">
										<span class="photo media-left"><img alt="avatar" src="images/avatar/3.jpg"></span>
										<div class="message media-body">
											<span class="name float-left">Cheryl Wheeler</span>
											<span class="time float-right">10 minutes ago</span>
											<p>Hello, this is an example msg</p>
										</div>
									</a>
									<a class="dropdown-item media" href="#">
										<span class="photo media-left"><img alt="avatar" src="images/avatar/4.jpg"></span>
										<div class="message media-body">
											<span class="name float-left">Rachel Santos</span>
											<span class="time float-right">15 minutes ago</span>
											<p>Lorem ipsum dolor sit amet, consectetur</p>
										</div>
									</a>
								</div>
							</div>
						</div>

						<div class="user-area dropdown float-right">
							<a href="#" class="dropdown-toggle active" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
								<img class="user-avatar rounded-circle" src="images/admin.jpg" alt="User Avatar">
							</a>

							<div class="user-menu dropdown-menu">
								<a class="nav-link" href="#"><i class="fa fa-user"></i>My Profile</a>

								<a class="nav-link" href="#"><i class="fa fa-bell-o"></i>Notifications <span class="count">13</span></a>

								<a class="nav-link" href="#"><i class="fa fa-cog"></i>Settings</a>

								<a class="nav-link" href="#"><i class="fa fa-power-off"></i>Logout</a>
							</div>
						</div>
					</div>
				</div>
			</header>
			<!-- /header -->
			<!-- Header-->

			<div class="breadcrumbs">
				<div class="breadcrumbs-inner">
					<div class="row m-0">
						<div class="col-sm-4">
							<div class="page-header float-left">
								<div class="page-title">
									<h1 id="hosName">医院名称</h1>
								</div>
							</div>
						</div>
						<div class="col-sm-8">
							<div class="page-header float-right">
								<div class="page-title">
									<ol class="breadcrumb text-right">
										<li>
											<a href="#">后台管理</a>
										</li>
										<li>
											<a href="#">医院</a>
										</li>
										<li class="active">更新</li>
									</ol>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>

			<div class="content">
				<div class="row" style="margin-bottom: 20px;">
					<div class="col-lg-12">
						<div class="card">
							<div class="card-header">
								<strong>详细信息</strong>
							</div>
							<div class="card-body card-block">
								<div class="row form-group">
									<div class="col col-md-3"><label for="text-input" class=" form-control-label">医院别名</label></div>
									<div class="col-12 col-md-9"><input type="text" id="alias" placeholder="别名" class="form-control"></div>
								</div>
								<div class="row form-group">
									<div class="col col-md-3"><label for="text-input" class=" form-control-label">院长</label></div>
									<div class="col-12 col-md-9"><input type="text" id="dean" placeholder="院长" class="form-control"></div>
								</div>
								<div class="row form-group">
									<div class="col col-md-3"><label for="email-input" class=" form-control-label">国家认证</label></div>
									<div class="col-12 col-md-9">
										<select id="select-isAuth" class="form-control">
											<option value="已认证">已认证</option>
											<option value="未认证">未认证</option>
										</select>
									</div>
								</div>
								<div class="row form-group">
									<div class="col col-md-3"><label for="password-input" class=" form-control-label">医院等级</label></div>
									<div class="col-12 col-md-9">
										<select id="select-level" class="form-control">
											<option value="">等级</option>
											<!--此处填充所有医院等级-->
										</select>
									</div>
								</div>
								<div class="row form-group">
									<div class="col col-md-3"><label for="disabled-input" class=" form-control-label">经营类型</label></div>
									<div class="col-12 col-md-9">
										<select id="select-type" class="form-control">
											<option value="">类型</option>
											<!--此处填充所有医院类型-->
										</select>
									</div>
								</div>
								<div class="row form-group">
									<div class="col col-md-3"><label for="text-input" class=" form-control-label">官方电话</label></div>
									<div class="col-12 col-md-9"><input type="text" id="tel" rows="9" placeholder="0000-00000000" class="form-control"></div>
								</div>
								<div class="row form-group">
									<div class="col col-md-3"><label for="textarea-input" class=" form-control-label">地址</label></div>
									<div class="col-12 col-md-9"><textarea id="addr" rows="3" placeholder="地址" class="form-control"></textarea></div>
								</div>
								<div class="row form-group">
									<div class="col col-md-3"><label for="textarea-input" class=" form-control-label">医院简介</label></div>
									<div class="col-12 col-md-9"><textarea id="info" rows="9" placeholder="医院简介" class="form-control"></textarea></div>
								</div>
								<div class="row form-group">
									<div class="col col-md-3"><label for="textarea-input" class=" form-control-label">医院科室</label></div>
									<div class="col-12 col-md-9"><textarea id="keshi" rows="9" placeholder="医院科室" class="form-control"></textarea></div>
								</div>
							</div>
							<div class="card-footer">
								<button type="submit" class="btn btn-primary btn-sm">
                                    <i class="fa fa-dot-circle-o"></i> Submit
                                </button>
								<button type="reset" class="btn btn-danger btn-sm">
                                    <i class="fa fa-ban"></i> Reset
                                </button>
							</div>
						</div>

					</div>

				</div>
				<div class="animated fadeIn">
					<div class="row">
						<div class="col-lg-12">
							<div class="card">
								<div class="table-stats order-table ov-h">

								</div>
								<!-- /.table-stats -->
							</div>
						</div>
						<div class="col-lg-8">
							<button class="btn btn-outline-info" type="submit" id="btn-save">保存</button>
							<button class="btn btn-outline-info" type="submit" id="btn-back" onclick="toback()">返回</button>
						</div>
						<div class="col-lg-4">

						</div>
					</div>
				</div>
				<!-- .animated -->
			</div>
			<!-- .content -->

			<div class="clearfix"></div>

			<footer class="site-footer">
				<div class="footer-inner bg-white">
					<div class="row">
						<div class="col-sm-6">
							Copyright &copy; 2018 XX Admin. More Templates
							<a href="http://www.cssmoban.com/" target="_blank" title="XX">XX</a> - Collect from
							<a href="http://www.cssmoban.com/" title="XX" target="_blank">XX</a>
						</div>
						<div class="col-sm-6 text-right"> Designed by Colorlib
						</div>
					</div>
				</div>
			</footer>

		</div>
		<!-- /#right-panel -->

		<!-- Right Panel -->

		<!-- Scripts -->
		<script src="assets/js/vendor/jquery-2.1.4.min.js"></script>
		<script src="assets/js/popper.min.js"></script>
		<script src="assets/js/bootstrap.min.js"></script>
		<script src="assets/js/jquery.matchHeight.min.js"></script>
		<script src="assets/js/main.js"></script>

		<script>
			var $ = jQuery.noConflict();

			//获取url参数
			function urlParam() {
				var str = location.href; //取得整个地址栏
				var param = str.split("=");
				console.log(decodeURI(param[1]));
				return decodeURI(param[1]);
			}
			//获取医院
			getHos(urlParam());

			//获取所有科室列表
			getLevelAll();

			//获取所有省
			getProvAll();

			//获取所有类型
			getTypeAll();

			function getHos(id) {
				jQuery.ajax({
					url: "http://127.0.0.1:8000/hospital/getByIf",
					data: {
						pageNum: 1,
						pageSize: 1,
						id: id,

					},
					type: 'POST',
					dataType: "json",
					//async: false,
					success: function(d) {
						console.log(d[0].isAuth);
						$("#hosName").html(d[0].hosName)
						$("#alias").val(d[0].alias)
						$("#dean").val(d[0].dean)
						$("#select-isAuth").val(d[0].isAuth)
						$("#select-level").val(d[0].level)
						$("#select-type").val(d[0].type.split("/")[1])
						$("#tel").val(d[0].tele)
						$("#addr").val(d[0].addr)
						$("#info").val(d[0].info)
						$("#keshi").val(d[0].keshi)
					}
				});
			}

			//等级
			function getLevelAll() {
				jQuery.ajax({
					url: "http://127.0.0.1:8000/hospital/allLevel",
					type: 'GET',
					dataType: "json",
					success: function(d) {
						for(i = 0; i < d.length; i++) {
							addElOption("select-level", d[i]);
							//console.log(d[i]);
						}
					}
				});
			}

			//类型
			function getTypeAll() {
				jQuery.ajax({
					url: "http://127.0.0.1:8000/hospital/allType",
					type: 'GET',
					dataType: "json",
					success: function(d) {
						for(i = 0; i < d.length; i++) {
							addElOption("select-type", d[i]);
							//console.log(d[i]);
						}
					}
				});
			}

			//省
			function getProvAll() {
				jQuery.ajax({
					url: "http://127.0.0.1:8000/addr/allProvice",
					type: 'GET',
					dataType: "json",
					success: function(d) {
						for(i = 0; i < d.length; i++) {
							if(d[i] == "直辖市") {
								addElOption("select-prov", "北京市");
								addElOption("select-prov", "上海市");
								addElOption("select-prov", "天津市");
								addElOption("select-prov", "重庆市");
							} else {
								addElOption("select-prov", d[i]);
							}
							//console.log(d[i]);
						}
					}
				});
			}

			function addElOption(container, obj) {
				var el = '<option value="' + obj + '">' + obj + '</option>';
				$("#" + container).append(el);
			}





			$("#btn-save").click(function() {
				var alias = $("#alias").val()
				var dean = $("#dean").val()
				var isAuth = $("#select-isAuth").val()
				var level = $("#select-level").val()
				var type = $("#select-type").val()
				var tel = $("#tel").val()
				var addr = $("#addr").val()
				var info = $("#info").val()
				var keshi = $("#keshi").val()
				jQuery.ajax({
					url: "http://127.0.0.1:8000/hospital/update",
					data: {
						id:urlParam(),
						alias: alias,
						dean: dean,
						isAuth: isAuth,
						level: level,
						type: type,
						tele: tel,
						addr: addr,
						info: info,
						keshi: keshi
					},
					type: 'POST',
					dataType: "json",
					//async: false,
					success: function(d) {
						if(d>0){
							alert("保存成功");
						}
					}
				});
			})

			function toback() {
				window.location.href = "hospital.html";
			}
		</script>
	</body>

</html>